package com.kaikeba.t31.ticket.service.impl;

import com.kaikeba.t31.core.service.impl.CrudServiceImpl;
import com.kaikeba.t31.ticket.po.TrainNumber;
import com.kaikeba.t31.ticket.service.ITrainNumberService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 车次服务实现
 *
 * @author Cui Yicheng
 * @since 2021/11/18
 */
@Service
public class TrainNumberServiceImpl extends CrudServiceImpl<TrainNumber> implements ITrainNumberService {
    @Override
    public List<String> listStartStations(String startStation) {
        TrainNumber trainNumber = new TrainNumber();
        trainNumber.setStartStation(startStation);
        return baseMapper.selectByQuery(trainNumber).stream().map(TrainNumber::getStartStation).distinct().collect(Collectors.toList());
    }

    @Override
    public List<String> listEndStations(String endStation) {
        TrainNumber trainNumber = new TrainNumber();
        trainNumber.setEndStation(endStation);
        return baseMapper.selectByQuery(trainNumber).stream().map(TrainNumber::getEndStation).distinct().collect(Collectors.toList());
    }
}
